\(\int \frac {\tan (x)}{\sec (x)-\tan (x)} \, dx\) [198]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [C] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 12, antiderivative size = 15 \[ \int \frac {\tan (x)}{\sec (x)-\tan (x)} \, dx=-x+\frac {\cos (x)}{1-\sin (x)} \]

[Out]

-x+cos(x)/(1-sin(x))

Rubi [A] (verified)

Time = 0.07 (sec) , antiderivative size = 15, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.250, Rules used = {4476, 2814, 2727} \[ \int \frac {\tan (x)}{\sec (x)-\tan (x)} \, dx=\frac {\cos (x)}{1-\sin (x)}-x \]

[In]

Int[Tan[x]/(Sec[x] - Tan[x]),x]

[Out]

-x + Cos[x]/(1 - Sin[x])

Rule 2727

Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> Simp[-Cos[c + d*x]/(d*(b + a*Sin[c + d*x])), x]
/; FreeQ[{a, b, c, d}, x] && EqQ[a^2 - b^2, 0]

Rule 2814

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])/((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[b*(x/d)
, x] - Dist[(b*c - a*d)/d, Int[1/(c + d*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d
, 0]

Rule 4476

Int[(u_.)*((b_.)*sec[(c_.) + (d_.)*(x_)]^(n_.) + (a_.)*tan[(c_.) + (d_.)*(x_)]^(n_.))^(p_), x_Symbol] :> Int[A
ctivateTrig[u]*Sec[c + d*x]^(n*p)*(b + a*Sin[c + d*x]^n)^p, x] /; FreeQ[{a, b, c, d}, x] && IntegersQ[n, p]

Rubi steps \begin{align*} \text {integral}& = \int \frac {\sin (x)}{1-\sin (x)} \, dx \\ & = -x+\int \frac {1}{1-\sin (x)} \, dx \\ & = -x+\frac {\cos (x)}{1-\sin (x)} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.08 (sec) , antiderivative size = 29, normalized size of antiderivative = 1.93 \[ \int \frac {\tan (x)}{\sec (x)-\tan (x)} \, dx=-x+\frac {2 \sin \left (\frac {x}{2}\right )}{\cos \left (\frac {x}{2}\right )-\sin \left (\frac {x}{2}\right )} \]

[In]

Integrate[Tan[x]/(Sec[x] - Tan[x]),x]

[Out]

-x + (2*Sin[x/2])/(Cos[x/2] - Sin[x/2])

Maple [C] (verified)

Result contains complex when optimal does not.

Time = 0.24 (sec) , antiderivative size = 17, normalized size of antiderivative = 1.13

method result size
risch \(-x +\frac {2}{{\mathrm e}^{i x}-i}\) \(17\)
default \(-2 \arctan \left (\tan \left (\frac {x}{2}\right )\right )-\frac {2}{\tan \left (\frac {x}{2}\right )-1}\) \(19\)

[In]

int(tan(x)/(sec(x)-tan(x)),x,method=_RETURNVERBOSE)

[Out]

-x+2/(exp(I*x)-I)

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 28, normalized size of antiderivative = 1.87 \[ \int \frac {\tan (x)}{\sec (x)-\tan (x)} \, dx=-\frac {{\left (x - 1\right )} \cos \left (x\right ) - {\left (x + 1\right )} \sin \left (x\right ) + x - 1}{\cos \left (x\right ) - \sin \left (x\right ) + 1} \]

[In]

integrate(tan(x)/(sec(x)-tan(x)),x, algorithm="fricas")

[Out]

-((x - 1)*cos(x) - (x + 1)*sin(x) + x - 1)/(cos(x) - sin(x) + 1)

Sympy [F]

\[ \int \frac {\tan (x)}{\sec (x)-\tan (x)} \, dx=\int \frac {\tan {\left (x \right )}}{- \tan {\left (x \right )} + \sec {\left (x \right )}}\, dx \]

[In]

integrate(tan(x)/(sec(x)-tan(x)),x)

[Out]

Integral(tan(x)/(-tan(x) + sec(x)), x)

Maxima [A] (verification not implemented)

none

Time = 0.30 (sec) , antiderivative size = 28, normalized size of antiderivative = 1.87 \[ \int \frac {\tan (x)}{\sec (x)-\tan (x)} \, dx=-\frac {2}{\frac {\sin \left (x\right )}{\cos \left (x\right ) + 1} - 1} - 2 \, \arctan \left (\frac {\sin \left (x\right )}{\cos \left (x\right ) + 1}\right ) \]

[In]

integrate(tan(x)/(sec(x)-tan(x)),x, algorithm="maxima")

[Out]

-2/(sin(x)/(cos(x) + 1) - 1) - 2*arctan(sin(x)/(cos(x) + 1))

Giac [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 14, normalized size of antiderivative = 0.93 \[ \int \frac {\tan (x)}{\sec (x)-\tan (x)} \, dx=-x - \frac {2}{\tan \left (\frac {1}{2} \, x\right ) - 1} \]

[In]

integrate(tan(x)/(sec(x)-tan(x)),x, algorithm="giac")

[Out]

-x - 2/(tan(1/2*x) - 1)

Mupad [B] (verification not implemented)

Time = 22.80 (sec) , antiderivative size = 14, normalized size of antiderivative = 0.93 \[ \int \frac {\tan (x)}{\sec (x)-\tan (x)} \, dx=-x-\frac {2}{\mathrm {tan}\left (\frac {x}{2}\right )-1} \]

[In]

int(-tan(x)/(tan(x) - 1/cos(x)),x)

[Out]

- x - 2/(tan(x/2) - 1)